{extend name='admin@main'}

{block name="content"}

{include file='store@package/form_style'}
<style>
    .layui-form-checkbox i{
        border-left: 1px solid #d2d2d2 !important;
    }
</style>
<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">

    <div class="layui-card-body think-box-shadow padding-left-40" >

        <div class="layui-form-item layui-row layui-col-space15" >

            <label class="layui-col-xs9 relative" style="width:50%">
                <span class="color-green">名称</span>
                <input name="title" required class="layui-input" placeholder="请输入名称" value="{$vo.title|default=''}">
            </label>



        </div>
        <div class="layui-form-item layui-row layui-col-space15" >


            <label class="layui-col-xs9 relative" style="width:50%">
                <span class="color-green">描述</span>
                <input name="desc"  class="layui-input" placeholder="请输入描述" value="{$vo.desc|default=''}">
            </label>

        </div>
        <div class="layui-form-item layui-row layui-col-space15" >

            标签（多选）
            <div>
                <?php foreach($brand_list as $k =>&$v){ ?>
                <div style="width: 20%;float: left">
                    <input type="checkbox" name="brand_name[]" <?php if(!empty($vo['brand_name'])){ if(strstr($vo['brand_name'],$v['title'])){ echo 'checked'; }} ?> value="<?php echo $v['title']; ?>"><?php echo $v['title']; ?>
                </div>
                <?php }?>
                <div style="clear: both"></div>
            </div>

        </div>

        <div class="layui-form-item layui-row layui-col-space15" >
            品系（多选）
            <div>
                <?php foreach($cate_list as $k =>&$v){ if(!empty($vo['cate_id'])){ $cate_arr = explode(',',$vo['cate_id']);}else{ $cate_arr = []; } ?>
                    <div style="width: 20%;float: left">
                        <input type="checkbox" name="cate_id[]" <?php if(!empty($vo['cate_id'])){ if(in_array($v['id'],$cate_arr)){ echo 'checked'; }} ?> value="<?php echo $v['id']; ?>"><?php echo $v['title']; ?>
                    </div>
                <?php }?>
                <div style="clear: both"></div>
            </div>
        </div>

        <div class="layui-form-item layui-row layui-col-space15" >
            症状（多选）
            <div>
                <?php foreach($symptom_list as $k =>&$v){ if(!empty($vo['symptom_id'])){ $symptom_arr = explode(',',$vo['symptom_id']);}else{ $symptom_arr = []; }?>
                    <div style="width: 20%;float: left">
                        <input type="checkbox" name="symptom_id[]" <?php  if(!empty($vo['symptom_id'])){ if(in_array($v['id'],$symptom_arr)){ echo 'checked'; }} ?> value="<?php echo $v['id']; ?>"><?php echo $v['title']; ?>
                    </div>
                <?php }?>
                <div style="clear: both"></div>
            </div>
        </div>

        <div class="layui-form-item layui-row layui-col-space15" >
            项目（多选）
            <div>
                <?php foreach($project_list as $k =>&$v){ if(!empty($vo['project_id'])){ $project_arr = explode(',',$vo['project_id']);}else{ $project_arr = []; } ?>
                    <div style="width: 20%;float: left">
                        <input type="checkbox" name="project_id[]" <?php if(!empty($vo['project_id'])){ if(in_array($v['id'],$project_arr)){ echo 'checked'; }} ?> value="<?php echo $v['id']; ?>"><?php echo $v['title']; ?>（<?php echo $v['price']; ?>）
                    </div>
                <?php }?>
                <div style="clear: both"></div>
            </div>
        </div>


        <div class="layui-form-item block" style="display: block !important;">
            <span class="label-required-prev color-green">详细内容</span>
            <textarea name="content">{$vo.content|default=''|raw}</textarea>
        </div>

        <div class="layui-form-item text-center">
            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
            <button class="layui-btn layui-btn-danger" ng-click="hsitoryBack()" type="button">取消编辑</button>
            <button class="layui-btn" type="submit">保存</button>
        </div>

    </div>
</form>
{/block}

{block name='script'}
<script>
    window.form.render();
    require(['ckeditor', 'angular'], function () {
        window.createEditor('[name="content"]', {height: 500});
        var app = angular.module("GoodsForm", []).run(callback);
        angular.bootstrap(document.getElementById(app.name), [app.name]);

        function callback($rootScope) {
            // 返回列表
            $rootScope.hsitoryBack = function () {
                $.msg.confirm('确定要取消编辑吗？', function (index) {
                    history.back(), $.msg.close(index);
                });
            };
            // 设置默认值
            $rootScope.setValue = function (key, type, value, call) {
                $rootScope.maps[key] || ($rootScope.maps[key] = {});
                return $rootScope.maps[key][type] = eval(call.replace('_', "'" + value + "'"));
            };
            // 读取默认值
            $rootScope.getValue = function (key, callback) {
                if (typeof callback === 'function') {
                    return callback($rootScope.maps[key] || {});
                }
                return {};
            };
            // 去除空白字符
            $rootScope.trimSpace = function (value) {
                return (value + '').replace(/\s*/ig, '');
            };
        }
    })
</script>
{/block}